#include<iostream>
using namespace std;
class Solution
{
public:
    int lengthOfLastWord(string s)
    {
        int index = s.size() - 1;
        while (s[index] == ' ')
            index--;
        int len = 0;
        while (index >= 0 && s[index] != ' ')
        {
            index--;
            len++;
        }
        return len;
    }
};
int main()
{
    return 0;
}